<div class="layui-fluid layui-anim febs-anim" id="febs-railway-el" lay-title="实体标注">
    <div class="layui-row febs-container">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body febs-table-full">
                    <form class="layui-form layui-table-form" lay-filter="railway-table-form">
                        <div class="layui-row">
                            <div class="layui-col-md10">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">来源文件</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="fileName" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">创建时间</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="createTime" id="createTime" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">实体标注</label>
                                        <div class="layui-input-inline">
                                            <select name="isEntity">
                                                <option value=""></option>
                                                <option value="0">未标注</option>
                                                <option value="1">标注过</option>
                                            </select>
                                        </div>
                                    </div>


                                </div>
                            </div>
                            <div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area">
                                <div class="layui-btn layui-btn-sm layui-btn-primary table-action" id="query">
                                    <i class="layui-icon">&#xe848;</i>
                                </div>
                                <div class="layui-btn layui-btn-sm layui-btn-primary table-action" id="reset">
                                    <i class="layui-icon">&#xe79b;</i>
                                </div>

                            </div>
                        </div>
                    </form>
                    <table lay-filter="railwayTableEl" lay-data="{id: 'railwayTableEl'}"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="railway-isEntity">
    {{#
    var isEntity = {
    1: {title: '标注过', color: 'green'},
    0: {title: '未标注', color: 'volcano'}
    }[d.isEntity];
    }}
    <span class="layui-badge febs-tag-{{isEntity.color}}">{{ isEntity.title }}</span>
</script>
<script type="text/html" id="railway-option">
    <span shiro:lacksPermission="railway:update">
        <span class="layui-badge-dot febs-bg-orange"></span> 无权限
    </span>
    <a lay-event="edit" shiro:hasPermission="railway:update"><i
            class="layui-icon febs-edit-area febs-blue">&#xe7a4;</i></a>

</script>
<script data-th-inline="javascript">
   var tag=[[${tag}]];
</script>
<script data-th-inline="none" type="text/javascript">
    layui.use(['dropdown', 'jquery', 'laydate', 'form', 'table', 'febs', 'treeSelect'], function () {
        var $ = layui.jquery,
            laydate = layui.laydate,
            febs = layui.febs,
            form = layui.form,
            table = layui.table,
            $view = $('#febs-railway-el'),

            $query = $view.find('#query'),
            $reset = $view.find('#reset'),
            $searchForm = $view.find('form'),
            sortObject = {field: 'createTime', type: null},
            tableIns;

        form.render();

        initTable();

        laydate.render({
            elem: '#createTime',
            range: true,
            trigger: 'click'
        });




        table.on('tool(railwayTableEl)', function (obj) {
            var data = obj.data,
                layEvent = obj.event;

            if (layEvent === 'edit') {
                febs.modal.open('实体标注', 'mark/el/elMarkResult/'+ data.railwayId, {
                    area: $(window).width() <= 750 ? '90%' : '70%',
                    offset:'100px',
                    btn: ['提交', '取消'],
                    yes: function (index, layero) {
                        $('#el-update').find('#submit').trigger('click');
                    },
                    btn2: function () {
                        layer.closeAll();
                    }
                });
            }
        });

        table.on('sort(railwayTableEl)', function (obj) {
            sortObject = obj;
            tableIns.reload({
                initSort: obj,
                where: $.extend(getQueryParams(), {
                    field: obj.field,
                    order: obj.type
                })
            });
        });

        $query.on('click', function () {
            var params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type});
            tableIns.reload({where: params, page: {curr: 1}});
        });

        $reset.on('click', function () {
            $searchForm[0].reset();
            sortObject.type = 'null';
            tableIns.reload({where: null, page: {curr: 1}, initSort: sortObject});
        });

        function initTable() {
            tableIns = febs.table.init({
                elem: $view.find('table'),
                id: 'railwayTableEl',
                url: ctx + 'railway/listEl/'+tag,
                cols: [[

                    {field: 'fileName', title: '来源文件', width: 180},
                    {field: 'originContent', title: '原始文本'},
                    {field: 'segWords', title: '人工校对后的分词结果'},
                    {title: '是否实体标注', templet: '#railway-isEntity',width: 130},
                    {field: 'entityWordsFront', title: '实体标注后的结果'},
                    {field: 'createTime', title: '创建时间', width: 180, sort: true},
                    {title: '操作', toolbar: '#railway-option', width: 80}
                ]]
            });
        }

        function getQueryParams() {
            var createTimeFrom,
                createTimeTo,
                createTime = $searchForm.find('input[name="createTime"]').val();
            if (createTime) {
                createTimeFrom = createTime.split(' - ')[0];
                createTimeTo = createTime.split(' - ')[1];
            }
            debugger;
            return {
                createTimeFrom: createTimeFrom,
                createTimeTo: createTimeTo,
                fileName: $searchForm.find('input[name="fileName"]').val().trim(),
                isEntity: $searchForm.find("select[name='isEntity']").val(),
                invalidate_ie_cache: new Date()
            };
        }


    })
</script>